import { Module, Global, Provider } from '@nestjs/common';
import { IConfigure } from '@type/configure';
// const CONFIGURE = process.env
console.log(process.env.NODE_ENV);
const Configure: IConfigure  = process.env.NODE_ENV === 'development'? require('./configure.dev').configure : require('./configure.pro').configure;

const providers: Provider[] = [
    {
        provide: 'APP_PREFIX',
        useValue: Configure.appPrefix
    },
    {
        provide: 'DATABASE_CONFIGURE',
        useValue: Configure.database
    }
]
@Global()
@Module({})
export class ConfigureModule {
    static forRoot() {
        return {
            global: true,
            module: ConfigureModule,
            imports: [],
            controllers: [],
            providers: [
                ...providers
            ],
            exports: [
                ...providers
            ]
        }
    }
}
export const configure = Configure;